package com.mrwind.windMission.controller;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.mrwind.common.factory.JSONFactory;
import com.mrwind.daoService.test.BsTestDaoService;
import com.mrwind.pgsql.orm.mapper.entity.Test;

@Controller
public class TestController {

	@Autowired
	private BsTestDaoService bsTestDaoService;
	
	@RequestMapping(value="test/", method = RequestMethod.GET)
	@ResponseBody
	public JSON getTestById(@RequestParam(value="id",required=true) String id,HttpServletResponse response){
		Test test = bsTestDaoService.findTestById(id);
		if(test!=null){
			response.setStatus(200);
			JSONObject json = JSONFactory.getSuccessJSON();
			json.put("text", test);
			return json;
		}
		response.setStatus(200);
        return JSONFactory.getSuccessJSON("没有记录");
	}
}
